home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
MacWorld 2000 February
/
Macworld (2000-02).dmg
/
Games World
/
Hot demos!
/
Starbound II
/
AI agents
/
Gypsum 1.00
/
Gypsum 1.00.rsrc
/
ss$t_146
< prev
next >
Wrap
Text File
|
1999-10-30
|
2KB
|
73 lines
situation space_unit
// Approach: Send all ships after the ship with the lowest shields
vars
me : ship;
mx : integer;
my : integer;
i : integer;
s : ship;
low_ship : ship;
low_shield : integer;
success : boolean;
tx : integer;
ty : integer;
dist : integer;
function CheckShip(target : ship) : ship;
vars
sum : integer;
begin
sum := Space_fore_shield(target) +
Space_aft_shield(target) +
Space_port_shield(target) +
Space_starboard_shield(target);
if low_ship = nil then
begin
low_ship := target;
low_shield := sum;
end;
else if sum < low_shield then
begin
low_ship := target;
low_shield := sum;
end;
return Next_ship(target);
end;
begin
// Get yourself
me := This_ship();
mx := Get_space_x(me);
my := Get_space_y(me);
// Activate all of your systems
i := 0;
while (i < 6) do
begin
// We don't want to turn on the self destruct system
if (Fire_system(My_race(), Space_class(me), Space_gen(me), i) <> 73) then
success := Set_fire_status(me, i, true);
i := i + 1;
end;
// Determine which ship to attack, based on lowest shields
low_ship := nil;
low_shield := 0;
s := First_ship(false);
while (s <> nil) do
s := CheckShip(s);
if low_ship <> nil then
begin
success := Set_space_target(me, low_ship);
// The ship will automatically move toward the target
end;
end;